<?php
namespace Mentees\Controller;

class JobController extends MainController {

    public function index(){
        $cate = I('get.cate');
        $map['show']=1;
        $train = M('TrainCate')->field('id,name')->where($map)->order('sort asc,id asc')->select();
        $this->assign('train',$train);
        $this->assign('cate',$cate);

        unset($map);
        if ($cate) {
            $map['trainID'] =array("like","%-".$cate."-%");
        }

        $obj = M('Job');
        $count = $obj->where($map)->count();
        import("Common.ORG.Page");
        $page = new \Page($count, 20);
        $show = $page->show();
        $list = $obj->where($map)->order('id desc')->limit($page->firstRow . ',' . $page->listRows)->select();
        $this->assign('list', $list);
        $this->assign('page', $show);

        $this->display();
    }

    //请求详情
    public function view(){
        $id = (int)I('get.id');
        $obj = M('Job');
        $map['id']=$id;
        $list = $obj->where($map)->find();
        if (!$list) {
            $this->error(L('_public_noinfo'));
        } else {
            unset($map);
            $this->assign('list',$list);
            $this->display();
        }
    }
}
